package exam.bak.beike;

import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class P3 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int[] params = Arrays.stream(scanner.nextLine().trim().split(" ")).mapToInt(s -> Integer.parseInt(s)).toArray();
        int n = params[0];
        int k = params[1];
        int m = params[2];
        int[] values = Arrays.stream(scanner.nextLine().trim().split(" ")).mapToInt(s -> Integer.parseInt(s)).toArray();
        System.out.println(tanxin(values, n, k, m));

       /* List<Integer> resultList = new ArrayList<>();
        resultList.add(0);
        backTrack(values, 0, m, k, new ArrayList<>(), resultList);
        System.out.println(resultList.get(0));*/
    }


    private static int tanxin(int[] values, int n, int k, int m) {
        Arrays.sort(values);
        int pos = Arrays.binarySearch(values, m);
        if (pos < 0) {
            pos = -1 * pos - 1;
        } else {
            pos--;
        }
        int total = 0;
        int times = (pos + 1) / 2;
        for (int i = n - 1; i >= n - times; i--) {
            total += values[i];
        }
        for (int i = 0; i < (n - times * (k + 1)); i++) {
            total += values[pos--];
        }
        return total;
    }

    private static void backTrack(int[] values, int pos, int m, int k, List<Integer> savedList, List<Integer> resultList) {
        if (pos >= values.length) {
            System.out.println(savedList);
            int total = savedList.stream().mapToInt(s -> values[(int) s]).sum();
            if (total > resultList.get(0)) {
                resultList.set(0, total);
            }
        } else {
            for (int i = 0; i < values.length; i++) {
                if (!savedList.contains(i)) {
                    // 选
                    int value = values[i];
                    savedList.add(i);
                    if (value > m) {//越界
                        backTrack(values, pos + k + 1, m, k, savedList, resultList);
                    } else {
                        backTrack(values, pos + 1, m, k, savedList, resultList);
                    }
                    savedList.remove(savedList.size() - 1);
                    // 不选
                    backTrack(values, pos + 1, m, k, savedList, resultList);
                }
            }
        }
    }
}
